package org.nix.service;

import org.nix.dao.CityJpa;
import org.nix.entity.City;
import org.nix.utils.dijkstra.MyDijkstra;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Queue;

/**
 * Create by zhangpe0312@qq.com on 2018/4/19.
 */
@Service
public class CityService {

    @Autowired
    private CityJpa cityJpa;

    public Queue<City> getMinWay(City start , City end){
        MyDijkstra myDijkstra = new MyDijkstra();

        List<City> list = cityJpa.findAll();

        myDijkstra.dijkstraDistance(list,start,end);
        return myDijkstra.getWays();
    }

    public double getMinWayLength(City start , City end){
        MyDijkstra myDijkstra = new MyDijkstra();
        myDijkstra.dijkstraDistance(cityJpa.findAll(),start,end);
        return myDijkstra.getLength();
    }

}
